package com.transcasafe.eanpay.example.pay;

import com.alibaba.fastjson.JSONObject;
import com.transcasafe.eanpay.core.config.EanPayConfig;
import com.transcasafe.eanpay.core.service.EanPayCardService;
import com.transcasafe.eanpay.core.service.model.RefundPaymentRequest;
import com.transcasafe.eanpay.core.service.model.RefundPaymentResponse;
import com.transcasafe.eanpay.core.util.NonceUtil;
import com.transcasafe.eanpay.example.MchConfig;

/**
 * 3DS支付
 */
public class EanPayRefundServiceExample {
    public static void main(String[] args) {
        EanPayConfig config = new EanPayConfig.Builder().mchNo(MchConfig.mchNo).mchKey(MchConfig.mchKey).build();
        EanPayCardService service = new EanPayCardService.Builder().config(config).hostname(MchConfig.hostname).build();
        RefundPaymentRequest request = new RefundPaymentRequest();
        request.setMchRefundOrderNo(NonceUtil.createNonce(16));
        request.setOrderNo("CP20251015184310973PHB3AH");
        request.setRefundReason("Refund Test");

        request.setCurrency("USD"); // 可不传，默认为订单币种
        request.setRefundAmount("1"); // 可不传，默认为订单金额，全额退款
        RefundPaymentResponse response = service.refund(request);
        System.out.println(JSONObject.toJSONString(response));
    }
}
